﻿using System;
using System.Data;
using System.Configuration;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.ComponentModel;

namespace TA.Turbo.Controls
{
	internal class PostScenarioClient
	{
		public PostScenarioClient(PostScenario source)
		{
			this.Id = source.ClientID;
			this.PostUrl = source.PostUrl;
			this.HttpVerb = source.HttpVerb;
			this.PostMode = source.PostMode;
			this.ValidationGroupList = source.ValidationGroupList;
			this.IncludeHashString = source.IncludeHashString;
			this.CausesValidation = source.CausesValidation;
			this.Clean = source.Clean;
			this.OnPosting = source.Posting.Client;
			this.OnPosted = source.Posted.Client;
			this.OnResponse = source.Response.Client;
			this.OnResponseProcessed = source.ResponseProcessed.Client;
			this.OnError = source.Error.Client;

			this.ProgressControls = new List<string>();
			foreach (TurboProgress tp in TurboPage.Current.ProgressControls)
			{
				if(MultiPartValue.IsIncluded(tp.InclusionMode, tp.ScenarioList, source.ID))
					this.ProgressControls.Add(tp.ClientID);
			}

			this.PostControls = new List<ControlReferenceClient>();
			foreach (BaseControlReference cr in source.AllPostControls)
				this.PostControls.Add(new ControlReferenceClient(cr));

			this.ReturnControls = new List<ControlReferenceClient>();
			foreach (BaseControlReference cr in source.AllReturnControls)
				this.ReturnControls.Add(new ControlReferenceClient(cr));
		}



		public string Id { get; set; }
		public string PostUrl { get; set; }
		public HttpVerb HttpVerb { get; set; }
		public PostMode PostMode { get; set; }
		public List<string> ValidationGroupList { get; set; }
		public bool IncludeHashString { get; set; }
		public bool CausesValidation { get; set; }
		public bool Clean { get; set; }
		public string OnPosting { get; set; }
		public string OnPosted { get; set; }
		public string OnResponse { get; set; }
		public string OnResponseProcessed { get; set; }
		public string OnError { get; set; }
		public List<string> ProgressControls { get; set; }
		public List<ControlReferenceClient> PostControls { get; set; }
		public List<ControlReferenceClient> ReturnControls { get; set; }
	}
}